﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyOnlineScheduling
{
    class Task
    {
        public int duration;
        public int weight;
        public int arrivalTime;

        public void displayTask(int i)
        {
            Console.WriteLine("{0}. d:{1}, w:{2}, r:{3}", i, duration, weight, arrivalTime);
        }
    }

    class PartTask
    {
        public int taskId;
        public int completedPartDuration;
        public int pendingPartDuration;
        public int weight;
        public int arrivalTime;
        public int partDoneNow;

        public PartTask(Task[] tasks, int taskId)
        {
            this.taskId = taskId;
            this.arrivalTime = tasks[taskId].arrivalTime;
            weight = tasks[taskId].weight;
            completedPartDuration = 0;
            pendingPartDuration = tasks[taskId].duration;
        }

        public PartTask(PartTask clonedTask)
        {
            this.taskId = clonedTask.taskId;
            this.arrivalTime = clonedTask.arrivalTime;
            this.weight = clonedTask.weight;
            this.completedPartDuration = clonedTask.completedPartDuration;
            this.pendingPartDuration = clonedTask.pendingPartDuration;
            this.partDoneNow = 0;
        }

        public void displayTask(int i)
        {
            double percentage = (double)partDoneNow * 100.0 / (double)(completedPartDuration + pendingPartDuration);
            double dw = (double)(completedPartDuration + pendingPartDuration) / (double)weight;
            Console.WriteLine("{0}. id:{1}, w:{2}, {3}% ({6}/{7}), r:{4}, d/w:{5}", i, taskId, weight, percentage, arrivalTime, dw, partDoneNow, completedPartDuration + pendingPartDuration);
        }
    }
}
